package com.mycompany.dao.impl;

import com.mycompany.dao.UserDAO;
import com.mycompany.entity.PomodoroRol;
import com.mycompany.entity.PomodoroUser;
import javax.enterprise.inject.Alternative;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Alternative
public class UserEMDAOImpl implements UserDAO {

    @PersistenceContext(unitName = "pomodoro")
    private EntityManager em;

    @Override
    public PomodoroUser persist(PomodoroUser t) {
        this.em.persist(t);
        this.em.flush();
        this.em.refresh(t);
        return t;
    }

    @Override
    public PomodoroUser find(Object id) {
        return (PomodoroUser) this.em.find(PomodoroUser.class, id);
    }

    @Override
    public PomodoroUser getReference(PomodoroUser t) {
        return this.em.getReference(PomodoroUser.class, t);
    }

    @Override
    public void remove(PomodoroUser t) {
        this.em.remove(t);
    }

    @Override
    public PomodoroUser merge(PomodoroUser t) {
        this.em.merge(t);
        this.em.flush();
        this.em.refresh(t);
        return t;
    }

    @Override
    public void refresh(PomodoroUser t) {
        this.em.refresh(t);
    }
}
